package com.example.download.ViewModel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.example.download.R
import com.example.download.bean.downloaded_item

class CViewModel: ViewModel() {
    private var _downloadedItemList = MutableLiveData<MutableList<downloaded_item>>()
    val downloadedItemList: LiveData<MutableList<downloaded_item>> get() = _downloadedItemList
    init {

    }
    fun addNewItem(){
        val newItem = downloaded_item(
            tv_dle_item_imageView = R.drawable.b1,
            tv_dle_item_title = "How to unlock your iPhone with your Apple Watch -- Apple Support",
            tv_dle_item_date = "20.34MB",
            iv_dle_item_other = R.mipmap.other_menu
        )
        val updatedList = _downloadedItemList.value ?: mutableListOf()
        updatedList.add(newItem)
        _downloadedItemList.value = updatedList
    }
}